import request from '@/utils/request'
import { AxiosResponse } from 'axios'
import { ReqAddMemo, ReqChangeMemo } from '@/api/memo/type'

//备忘录请求地址
enum Memo_API {
  Add_Memo_URL = '/transaction_assistant/memos/add',
  Delete_Memo_URL = '/transaction_assistant/memos/delete/{id}',
  Change_Memo_URL = '/transaction_assistant/memos/change',
  Get_User_Memos_URL = '/transaction_assistant/memos/list',
  Get_Memo_Detail_URL = '/transaction_assistant/memos/detail/{id}',
}

//获取个人备忘录列表
export const getUserMemos = () =>
  request.get<any, AxiosResponse<any>>(Memo_API.Get_User_Memos_URL)

//修改个人备忘录
export const changeUserMemo = (params: ReqChangeMemo) =>
  request.put<any, AxiosResponse<any>>(Memo_API.Change_Memo_URL, params)

//增加个人备忘录
export const addUserMemo = (params: ReqAddMemo) =>
  request.post<any, AxiosResponse<any>>(Memo_API.Add_Memo_URL, params)

//删除个人备忘录
export const deleteUserMemo = (id: number) =>
  request.delete<any, AxiosResponse<any>>(
    Memo_API.Delete_Memo_URL.replace('{id}', id),
  )

//查看备忘录详情
export const getMemoDetail = (id: number) =>
  request.get<any, AxiosResponse<any>>(
    Memo_API.Get_Memo_Detail_URL.replace('{id}', id),
  )
